﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YmtAuth.Domain.Model.Safe;
using YmtAuth.Domain.Repository.MySql;

namespace YmtAuth.Domain.Repository
{
    public interface IUserLoginIpCountEntityRepository : IMySQLRepository<UserLoginIpCountEntity>
    {
        /// <summary>
        /// 检查是否需要计数（大于0表示需要增加计数）
        /// </summary>
        /// <param name="loginIp"></param>
        /// <param name="loginId"></param>
        /// <param name="minute"></param>
        /// <param name="loginSuccess"></param>
        /// <returns></returns>
        int CheckIsNeedCountIp(string loginIp, string loginId, int minute, bool loginSuccess,string userType);
        /// <summary>
        /// 添加计数
        /// </summary>
        /// <param name="loginIp"></param>
        /// <param name="minute"></param>
        /// <param name="loginSuccess"></param>
        /// <returns></returns>
        int AddUserLoginIpCount(string loginIp, int minute, bool loginSuccess, string userType);
        /// <summary>
        /// 获取计数
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="minute"></param>
        /// <param name="loginSuccess"></param>
        /// <returns></returns>
        int GetUserLoginIpCount(string ip, int minute,string userType, bool? loginSuccess = null);

        /// <summary>
        /// 重置最近统计周期的登录IP计数为0
        /// </summary>
        /// <param name="loginIp"></param>
        /// <param name="ipType"></param>
        /// <returns></returns>
        int ResetLatestLoginIPCount(string loginIp, int ipType);
    }
}
